//
//  MediaPlayerCommon.h
//  MediaPlayer
//
//  Created by Think on 2017/6/20.
//  Copyright © 2017年 Cell. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>

#define MEDIA_PLAYER_ERROR_PREFIX 88000

enum PLAYBACK_STATE{
    PREPARING           = 0x01,
    PREPARED            = 0x02,
    STARTED             = 0x04,
    PAUSED              = 0x10,
    STOPPED             = 0x20,
    INITIALIZED         = 0x80,
    COMPLETED           = 0x100,
    ERROR               = 0x200,
    SEEKING             = 0x1000,
};

enum media_player_info_type {
    MEDIA_PLAYER_INFO_PLAYBACK_STATE = 301,
    
    MEDIA_PLAYER_INFO_BUFFERING_START = 401,
    MEDIA_PLAYER_INFO_BUFFERING_END = 402,
    
    MEDIA_PLAYER_INFO_VIDEO_RENDERING_START = 403,
    
    MEDIA_PLAYER_INFO_NOT_SEEKABLE = 404,
    
    MEDIA_PLAYER_INFO_AUDIO_EOS = 405,
    
    MEDIA_PLAYER_INFO_ASYNC_PREPARE_ALREADY_PENDING = 406,
    
    MEDIA_PLAYER_INFO_MEDIA_DATA_EOF = 407,
    
    MEDIA_PLAYER_INFO_REAL_BITRATE = 501,
    MEDIA_PLAYER_INFO_REAL_FPS = 502,
    MEDIA_PLAYER_INFO_REAL_BUFFER_DURATION = 503,
    MEDIA_PLAYER_INFO_REAL_BUFFER_SIZE = 504,
    MEDIA_PLAYER_INFO_BUFFERING_DOWNLOAD_SIZE = 505,
    
    MEDIA_PLAYER_INFO_REQUEST_SERVER = 600,
    MEDIA_PLAYER_INFO_CONNECTED_SERVER = 601,
    MEDIA_PLAYER_INFO_DOWNLOAD_STARTED = 602,
    MEDIA_PLAYER_INFO_GOT_FIRST_KEY_FRAME = 603,
    MEDIA_PLAYER_INFO_GOT_FIRST_PACKET = 604,
    
    MEDIA_PLAYER_INFO_NO_AUDIO_STREAM = 201,
    MEDIA_PLAYER_INFO_NO_VIDEO_STREAM = 202,
    
    MEDIA_PLAYER_INFO_UPDATE_PLAY_SPEED = 1000,
    
    MEDIA_PLAYER_INFO_CURRENT_SOURCE_ID = 2000,

    //    MEDIA_PLAYER_INFO_AUDIO_VOLUME_CHANGED = 3000,

    MEDIA_PLAYER_INFO_RECORD_FILE_FAIL = 3000, //for record
    MEDIA_PLAYER_INFO_RECORD_FILE_SUCCESS = 3001, //for record

    //FOR ACCURATE_RECORDER
    MEDIA_PLAYER_INFO_ACCURATE_RECORDER_CONNECTED = 5001,
    MEDIA_PLAYER_INFO_ACCURATE_RECORDER_ERROR = 5003,
    MEDIA_PLAYER_INFO_ACCURATE_RECORDER_END = 5005,

    MEDIA_PLAYER_INFO_ACCURATE_RECORDER_INFO_PUBLISH_TIME = 5100,
    
    //FOR GRAB DISPLAY SHOT
    MEDIA_PLAYER_INFO_GRAB_DISPLAY_SHOT_SUCCESS = 6000,
    MEDIA_PLAYER_INFO_GRAB_DISPLAY_SHOT_FAIL = 6001,
    
    //FOR IOS VTB RESURRECTION
    MEDIA_PLAYER_INFO_IOS_VTB_RESURRECTION_START = 7000,
    MEDIA_PLAYER_INFO_IOS_VTB_RESURRECTION_END = 7001,
    
    //FOR PRELOAD
    MEDIA_PLAYER_INFO_PRELOAD_SUCCESS = 8000,
    MEDIA_PLAYER_INFO_PRELOAD_FAIL = 8001,
    
    //FOR SHORTVIDEO
    MEDIA_PLAYER_INFO_SHORTVIDEO_EOF_LOOP = 9000,
    
    //FOR SEAMLESS SWITCH STREAM
    MEDIA_PLAYER_INFO_SEAMLESS_SWITCH_STREAM_FAIL = 10000,
    
    //FOR AUDIO PROCESS
    MEDIA_PLAYER_INFO_VAD_STATE = 12000,
};

enum accurate_recorder_error_type {
    ACCURATE_RECORDER_ERROR_UNKNOWN = -1,
    ACCURATE_RECORDER_ERROR_CONNECT_FAIL = 0,
    ACCURATE_RECORDER_ERROR_MUX_FAIL = 1,
    ACCURATE_RECORDER_ERROR_COLORSPACECONVERT_FAIL = 2,
    ACCURATE_RECORDER_ERROR_VIDEO_ENCODE_FAIL = 3,
    ACCURATE_RECORDER_ERROR_AUDIO_CAPTURE_START_FAIL = 4,
    ACCURATE_RECORDER_ERROR_AUDIO_ENCODE_FAIL = 5,
    ACCURATE_RECORDER_ERROR_AUDIO_CAPTURE_STOP_FAIL = 6,
    ACCURATE_RECORDER_ERROR_POOR_NETWORK = 7,
    ACCURATE_RECORDER_ERROR_AUDIO_FILTER_FAIL = 8,
    ACCURATE_RECORDER_ERROR_OPEN_VIDEO_ENCODER_FAIL = 9,
};

enum media_player_error_type {
    MEDIA_PLAYER_ERROR_UNKNOWN = MEDIA_PLAYER_ERROR_PREFIX+201,
    
    MEDIA_PLAYER_ERROR_DEMUXER_READ_FAIL = MEDIA_PLAYER_ERROR_PREFIX+210,
    MEDIA_PLAYER_ERROR_VIDEO_DECODE_FAIL = MEDIA_PLAYER_ERROR_PREFIX+211,
    MEDIA_PLAYER_ERROR_AUDIO_DECODE_FAIL = MEDIA_PLAYER_ERROR_PREFIX+212,
    
    MEDIA_PLAYER_ERROR_SOURCE_URL_INVALID = MEDIA_PLAYER_ERROR_PREFIX+301,
    MEDIA_PLAYER_ERROR_DEMUXER_PREPARE_FAIL = MEDIA_PLAYER_ERROR_PREFIX+302,
    MEDIA_PLAYER_ERROR_VIDEO_DECODER_OPEN_FAIL = MEDIA_PLAYER_ERROR_PREFIX+303,
    MEDIA_PLAYER_ERROR_VIDEO_RENDER_OPEN_FAIL = MEDIA_PLAYER_ERROR_PREFIX+304,
    MEDIA_PLAYER_ERROR_AUDIO_PLAYER_PREPARE_FAIL = MEDIA_PLAYER_ERROR_PREFIX+305,
    MEDIA_PLAYER_ERROR_AUDIO_DECODER_OPEN_FAIL = MEDIA_PLAYER_ERROR_PREFIX+306,
    MEDIA_PLAYER_ERROR_AUDIO_FILTER_OPEN_FAIL = MEDIA_PLAYER_ERROR_PREFIX+307,
    
    MEDIA_PLAYER_ERROR_DEMUXER_UPTATE_STREAMINFO_FAIL = MEDIA_PLAYER_ERROR_PREFIX+401,
    
    MEDIA_PLAYER_ERROR_DEMUXER_TIMEOUT_FAIL = MEDIA_PLAYER_ERROR_PREFIX+501,
    MEDIA_PLAYER_ERROR_DEMUXER_DNS_RESOLVER_FAIL = MEDIA_PLAYER_ERROR_PREFIX+502,
    
    MEDIA_PLAYER_ERROR_NETWORK_SIWTCH = MEDIA_PLAYER_ERROR_PREFIX+1000,
    MEDIA_PLAYER_ERROR_NETWORK_BROKEN = MEDIA_PLAYER_ERROR_PREFIX+1001,
};

enum DataSourceType {
    UNKNOWN = 0,
    LIVE_HIGH_DELAY = 1,
    LIVE_LOW_DELAY = 2,
    VOD_HIGH_CACHE = 3,
    VOD_LOW_CACHE = 4,
    LOCAL_FILE = 5,
    VOD_QUEUE_HIGH_CACHE = 6,
    REAL_TIME = 7,
    
    PPBOX_DATA_SOURCE = 10,
    PPY_DATA_SOURCE = 11,
    PPY_SHORT_VIDEO_DATA_SOURCE = 12,
    PPY_PRELOAD_DATA_SOURCE = 13,
    
    SEAMLESS_STITCHING_DATA_SOURCE = 20,
    PRESEEK_DATA_SOURCE = 21,
    SEAMLESS_SWITCH_STREAM_DATA_SOURCE = 22,
};

enum FILTER_TYPE {
    FILTER_RGB = 0,
    FILTER_SKETCH = 1,
    FILTER_AMARO = 2,
    FILTER_ANTIQUE = 3,
    FILTER_BLACKCAT = 4,
    FILTER_BEAUTY = 5,       // 0.0f - 1.0f
    FILTER_BRANNAN = 6,
    FILTER_N1977 = 7,
    FILTER_BROOKLYN = 8,
    FILTER_COOL = 9,
    FILTER_CRAYON = 10,
    
    FILTER_BRIGHTNESS = 11,  // -1.0f - 1.0f
    FILTER_CONTRAST = 12,    // 0.0f - 4.0f
    FILTER_EXPOSURE = 13,    // -10.0f - 10.0f
    FILTER_HUE = 14,         // 0.0f - 360.0f
    FILTER_SATURATION = 15,  // 0.0f - 2.0f
    FILTER_SHARPEN = 16,     // -4.0f - 4.0f
    
    FILTER_NUM = 17,
};

enum VideoScalingMode
{
    VIDEO_SCALING_MODE_SCALE_TO_FILL = 0,
    VIDEO_SCALING_MODE_SCALE_TO_FIT = 1,
    VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING = 2,
};

enum VideoRotationMode
{
    VIDEO_NO_ROTATION = 0,
    VIDEO_ROTATION_LEFT = 1,
    VIDEO_ROTATION_RIGHT = 2,
    VIDEO_ROTATION_180 = 3,
};

enum VideoMaskMode
{
    ALPHA_CHANNEL_NONE = 0,
    ALPHA_CHANNEL_RIGHT = 1,
    ALPHA_CHANNEL_LEFT = 2,
    ALPHA_CHANNEL_UP = 3,
    ALPHA_CHANNEL_DOWN = 4,
};

// user-defined effects.
enum UserDefinedEffect {
    ATMOS = 0,     //全景声
    BASS,          //超重低音
    ENHANCEDVOICE, //清澈人声
    METAL,         //金属风
    ROTATE3D,      //旋转3D
    CHORUS,        //和声
    INTANGIBLE,    //空灵
    NOEFFECT
};

// define Equalizer style
enum EqualizerStyle {
    POPULAR = 0, //流行
    DANCE,       //律动
    BLUES,       //忧郁
    CLASSICAL,   //复古
    JUZZ,        //爵士
    LIGHT,       //舒缓
    ELECTRICAL,  //电音
    ROCK,        //摇滚
    PHONOGRAPH,  //留声机
    NOEQUALIZER
};

// define Reverb style
enum ReverbStyle {
    KTV = 0,  //KTV
    THEATER,  //剧场
    CONCERT,  //音乐会
    STUDIO,   //录音棚
    NOREVERB
};

enum MEDIA_PLAYER_MODE
{
    SYSTEM_MEDIA_PLAYER_MODE = 1,
    PRIVATE_MEDIA_PLAYER_MODE = 2,
    SHORT_VIDEO_EDIT_PREVIEW_MODE = 3,
};

enum VIDEO_DECODE_MODE
{
    AUTO_MODE            = 0,
    SOFTWARE_DECODE_MODE = 1,
    HARDWARE_DECODE_MODE = 2,
};

enum VIDEO_DECODER_TYPE
{
    FFMPEG = 0,
    OPENH264 = 1,
};

enum RECORD_MODE
{
    NO_RECORD_MODE = 0,
    BACKWARD_RECORD_MODE = 1,
    FORWARD_RECORD_MODE = 2,
    BACKWARD_FORWARD_RECORD_MODE = 3,
};

@interface MediaPlayerOptions : NSObject

- (instancetype) init;

@property (nonatomic) int media_player_mode;
@property (nonatomic) int video_decode_mode;
@property (nonatomic) BOOL pause_in_background;
@property (nonatomic) int record_mode;
@property (nonatomic) NSString* backupDir;
@property (nonatomic) BOOL isAccurateSeek;
@property (nonatomic) NSString* http_proxy;
@property (nonatomic) BOOL disableAudio;
@property (nonatomic) BOOL enableAsyncDNSResolver;
@property (nonatomic) BOOL isControlAVAudioSession;
@property (nonatomic) BOOL isSpokenAudioMixWithOthers;
@property (nonatomic) BOOL isVideoOpaque;
@end

@interface AccurateRecorderOptions : NSObject

- (instancetype) init;

@property (nonatomic, strong) NSString *publishUrl;

@property (nonatomic) BOOL hasVideo;
@property (nonatomic) CGSize videoSize;
@property (nonatomic) BOOL hasAudio;
@property (nonatomic) NSInteger bitrateKbps;
@property (nonatomic) NSInteger fps;
@property (nonatomic) NSInteger maxKeyFrameIntervalMs;

@end
